/**
 *	模块的
 *	开发者：雨中磐石
 *	地址：www.rockoa.com
 *	日期：2023-07-25
 */

package com.framework.Model;

import com.framerock.db.DB;
import com.framerock.db.DBConn;
import com.framerock.baselib.Rock;
import com.framework.ACore.Model;

import java.util.ArrayList;
import java.util.Map;


public class ModelMode extends Model {

    public ModelMode(DBConn dbs) {
        super(dbs);
        this.setTable("flowset");
    }

    public static ModelMode get(DBConn dbs)
    {
        return new ModelMode(dbs);
    }

    //获取下拉框模块的数据
    public ArrayList<Map<String, String>> getMdearr(String where)
    {
        String owhere = "`status`=1";
        if(!Rock.isEmpt(where))owhere+=" and "+where+"";
        ArrayList<Map<String, String>> rows = this.getAll(owhere, "`type`,`id`,`num`,`name`", "`sort`");
        return rows;
    }

    public ArrayList<Map<String, String>> getMdearr()
    {
        return getMdearr("");
    }

    /**
     * 快速添加模块
     * @param cid 单位id
     * */
    public ArrayList<Map<String, String>> getSelarr(String cid, String sid)
    {
        String where = "`isxt`=2 AND `status`=1 AND `istj`=1";
        String fields = ",(select count(1) from `"+ DB.chuliPerfix("flowunit")+"` c where c.`cid`="+cid+" AND c.`modeid` = `"+DB.chuliPerfix("flowset")+"`.`id`) as stotal";
        if(!Rock.isEmpt(sid)){
            where += " AND `id` in("+sid+")";
            fields = "";
        }
        ArrayList<Map<String, String>> rows = this.getAll(where, "`type`,`id`,`num`,`name`,`imgurl`"+fields+"", "`sort` ASC, `type` ASC");
        return rows;
    }
}
